/*
 * @Author: yangni 920556271@qq.com
 * @Date: 2023-12-07 09:26:03
 * @LastEditors: yangni 920556271@qq.com
 * @LastEditTime: 2024-05-16 10:50:41
 * @FilePath: /yt-devops/lib/model/device_obj/properties_model.dart
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import 'package:json_annotation/json_annotation.dart';
import 'package:yt_devops/model/data_type_config.dart';
import 'package:yt_devops/model/device_obj/authority_config_model.dart';
import 'package:yt_devops/model/device_obj/prompt_rule_model.dart';
import 'package:yt_devops/utils/enums.dart';

import 'product_config_model.dart';

part 'properties_model.g.dart';

@JsonSerializable()
class PropertiesModel extends ProductConfigModel {
  DataTypeConfig? dataType;

  DeviceModelShowType? showType;

  String? tip;

  String? disbaled;

  int? deviceId;

  List? buttons;
  // 默认值
  dynamic defaultValue;

  bool? required;

  List<PromptRuleModel>? promptRule;

  PropertiesModel(
      {super.authority,
      this.dataType,
      this.showType,
      this.disbaled,
      this.tip,
      required super.id,
      super.name,
      super.parentId,
      this.buttons,
      this.deviceId,
      this.defaultValue,
      this.promptRule,
      this.required})
      : super(
          type: DeviceConfigType.property,
        );

  factory PropertiesModel.fromJson(Map<String, dynamic> json) =>
      _$PropertiesModelFromJson(json);

  Map<String, dynamic> toJson() => _$PropertiesModelToJson(this);

  PropertiesModel copyWith(
      {DataTypeConfig? dataTypeCope,
      DeviceModelShowType? showTypeCope,
      String? tipCope,
      String? disbaledCope,
      int? deviceIdCope,
      String? idCope,
      String? nameCope,
      int? sortOrderCope,
      String? parentIdCope,
      List? buttonsCope,
      List<AuthorityModelConfig>? authorityCope}) {
    return PropertiesModel(
      dataType: dataTypeCope ?? dataType,
      showType: showTypeCope ?? showType,
      tip: tipCope ?? tip,
      disbaled: disbaledCope ?? disbaled,
      deviceId: deviceIdCope ?? deviceId,
      id: idCope ?? id,
      name: nameCope ?? name,
      parentId: parentIdCope ?? parentId,
      buttons: buttonsCope ?? buttons,
      authority: authorityCope ?? authority,
    );
  }
}
